﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using VK.Comm;

namespace VK.Casemeet.Links
{
    public static class LinkHelper
    {
        public static ListItem[] ObjectTypeData = new ListItem[11]{
            new ListItem("合作伙伴", "1"),
            new ListItem("联盟盟友", "30"),
            new ListItem("户外网站", "31"),
            new ListItem("西北地区", "37"),
            new ListItem("西南地区", "39"),
            new ListItem("东北地区", "38"),
            new ListItem("华东地区", "35"),
            new ListItem("华南地区", "36"),
            new ListItem("华北地区", "33"),
            new ListItem("华中地区", "34"),
            new ListItem("户外商城", "40")
        };

        public static void BindTypeRad(RadioButtonList control)
        {
            control.Items.Clear();
            control.Items.AddRange(ObjectTypeData);

            control.DataBind();
            control.SelectedIndex = 1;
        }

        public static string GetTypeLabel(int type)
        {
            string result = string.Empty;
            var items = ObjectTypeData.Where(p => p.Value == type.ToString());
            if (items.Count() > 0)
            {
                result = items.First().Text;
            }
            return result;
        }

        public static void BindTypeDDL(DropDownList control, OptionType optionType)
        {
            control.Items.Clear();
            control.Items.AddRange(ObjectTypeData);
            switch (optionType)
            {
                case OptionType.Default: break;
                case OptionType.Search: control.Items.Insert(0, new ListItem("全部", "0")); break;
                case OptionType.Select: control.Items.Insert(0, new ListItem("请选择", "0")); break;
            }
            control.SelectedIndex = 0;
        }
    }
}
